import { useRef, useState } from 'react';
import { v4 as uuidV4 } from 'uuid';
import { ProTable } from '@ant-design/pro-components';
import {
  Button,
  Select,
  Modal,
  message,
  Form,
  Input,
  Upload,
  Menu,
  Dropdown,
  Table,
  Typography,
  Tag,
} from 'antd';
import { PageContainer } from '@ant-design/pro-components';
import {
  couponSearch,
  couponArchive,
  couponSummarize,
  accountMove,
  searchBatch,
  usecouponBatch,
} from '@/services/place';
import type { ParamsType } from '@ant-design/pro-components';
import type { ProColumns } from '@ant-design/pro-table';
import type { PaginationProps, FormInstance } from 'antd';
import type { ActionType } from '@ant-design/pro-components';
import { DownOutlined } from '@ant-design/icons';
import StorageManager from '@/utils/StorageManager';
import { EnumElecStatusOption } from '@/utils/constant';
import type { UploadFile, UploadProps } from 'antd/es/upload/interface';

import styles from './style.less';
import { isEmpty } from 'lodash';

const filterPlaEnum = {
  1: '请输入券号',
  2: '请输入用户标识',
  3: '请输入用户手机号',
};

const filterNameEnum = {
  1: 'couponCode',
  2: 'userCode',
  3: 'mobile',
};

const defaultFolderValue = { folder: 'temp', expires: 1 };
// fileName: uuidV4(),

const SensitizeManageList: React.FC = () => {
  const actionRef = useRef<ActionType>();
  const formRef = useRef<FormInstance>();
  const [filterForm] = Form.useForm();
  const [modalNumForm] = Form.useForm();
  const [confirmLoad, setConfirmLoad] = useState<boolean>(false);
  const [modelNumVisible, setModelNumVisible] = useState<boolean>(false);
  const [modelText, setModelText] = useState<string>('');
  const filterTypeWatch = Form.useWatch('filterType', filterForm);
  const eunmList: any = StorageManager.getLocalStorageSync('eunmList');
  const [couponSumVisible, setCouponSumVisible] = useState<boolean>(false);
  const [dataSource, setDataSource] = useState<any>([]);
  const [fileList, setFileList] = useState<UploadFile[]>([]);
  const [fileUrlBro, setFileUrlBro] = useState<string>();
  const [folder, setFolder] = useState<any>(defaultFolderValue);
  const [loading, setLoading] = useState<boolean>(false);
  const [sumText, setSumText] = useState<string>('');
  const [elecVisible, setElecVisible] = useState<boolean>(false);
  const [modalElecForm] = Form.useForm();
  // @ts-ignore
  const [queryText, setQueryText] = useState<string>('');

  const getBrandList = (list: any[]) => {
    const listBro = list;
    listBro.forEach((item) => {
      item.label = item.value + '-' + item.label;
    });
    return listBro;
  };
  const OptionsBrandList = getBrandList(eunmList?.OptionsBrandList || []);

  // 提交
  const handleOperate = async (record: any, type: string) => {
    if (type === '显示明显') {
      setSumText('券明细信息');
      setCouponSumVisible(true);
      return;
    }
  };

  // 刷新
  const handleItem = async (record: any, type: string) => {
    if (type === '配置三方资产') {
      // const { code, data } = await assetDetail({
      //   assetId: record.activityId,
      // });
      // if (code === 200 && data) {
      // }
    }
    Modal.confirm({
      content: `确认${type}活动：${record.activityId}？`,
      async onOk() {
        // if (type === '刷新') {
        //   const { code, data } = await profileActivate({
        //     activityIds: record.activityId,
        //   });
        //   if (code === 200 && data) {
        //     message.success('操作成功');
        //     actionRef?.current?.reloadAndRest?.();
        //   }
        // }
      },
      onCancel() {},
    });
  };

  // 操作列--对应展示情况
  const handleDisplayRecord = (record: any, type: string) => {
    if (type === '操作') {
      if (
        (record.useStatus === 0 && record.reusableCount <= 1) ||
        [1, 2, 3].includes(record.useStatus)
      ) {
        return true;
      }
      return false;
    }
    if (type === '清当天限制') {
      if (
        (record.useStatus === 0 && record.reusableCount <= 1) ||
        [1, 2, 3].includes(record.useStatus)
      ) {
        return true;
      }
      return false;
    }
    if (type === '纠正次数') {
      if (
        (record.useStatus === 0 && record.reusableCount <= 1) ||
        [1, 2, 3].includes(record.useStatus)
      ) {
        return true;
      }
      return false;
    }
    if (type === '检查次数') {
      if (
        (record.useStatus === 0 && record.reusableCount <= 1) ||
        [1, 2].includes(record.useStatus)
      ) {
        return true;
      }
      return false;
    }
    if (type === '查找相同订单') {
      if (record.useStatus === 1) {
        return true;
      }
      return false;
    }
    if (type === '核销流水') {
      if ([2, 3].includes(record.useStatus)) {
        return true;
      }
      return false;
    }
    if (type === '取消预约') {
      // bookingCoupon为空禁用
      if (!isEmpty(record.bookingCoupon)) {
        return true;
      }
      return false;
    }
    return true;
  };

  // 操作列渲染
  const getItems = (record: any) => {
    return (
      <Menu>
        {handleDisplayRecord(record, '核销流水') && (
          <Menu.Item key="hexiao">
            <a
              onClick={() => {
                handleItem(record, '核销流水');
              }}
            >
              核销流水
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '操作') && (
          <Menu.Item key="caozuo">
            <a
              onClick={() => {
                handleItem(record, '操作');
              }}
            >
              操作
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '查找相同订单') && (
          <Menu.Item key="chazhao">
            <a
              onClick={() => {
                handleItem(record, '查找相同订单');
              }}
            >
              查找相同订单
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '清当天限制') && (
          <Menu.Item key="qingdang">
            <a
              onClick={() => {
                handleItem(record, '清当天限制');
              }}
            >
              清当天限制
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '纠正次数') && (
          <Menu.Item key="jiuzheng">
            <a
              onClick={() => {
                handleItem(record, '纠正次数');
              }}
            >
              纠正次数
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '检查次数') && (
          <Menu.Item key="jiancha">
            <a
              onClick={() => {
                handleItem(record, '检查次数');
              }}
            >
              检查次数
            </a>
          </Menu.Item>
        )}
        {handleDisplayRecord(record, '取消预约') && (
          <Menu.Item key="yuyue">
            <a
              onClick={() => {
                handleItem(record, '取消预约');
              }}
            >
              取消预约
            </a>
          </Menu.Item>
        )}
      </Menu>
    );
  };

  const columns: ProColumns<API.CouponSearchListItem>[] = [
    // 表格
    {
      title: '用户标识',
      dataIndex: 'userCode',
      ellipsis: true,
      width: 180,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '券号',
      dataIndex: 'couponCode',
      ellipsis: true,
      width: 180,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '券名',
      dataIndex: 'activity',
      ellipsis: true,
      width: 190,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '使用状态',
      dataIndex: 'activity',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
      render(_, record: any) {
        return (
          <div key={record.id}>
            {record.useStatus === 0 && record.reusableCount <= 1 && <Tag color="green">未使用</Tag>}
            {record.useStatus === 0 && record.reusableCount > 1 && (
              <>
                已使用{record.usedSeqId}/总次数{record.reusableCount}
              </>
            )}
            {record.useStatus === 1 && <Tag color="#c62d2e">已核销</Tag>}
            {record.useStatus === 2 && <Tag color="#D9B300">已销毁</Tag>}
            {record.useStatus === 3 && <Tag color="#c62d2e">次数用完</Tag>}
          </div>
        );
      },
    },
    {
      title: '是否转增',
      dataIndex: 'givingStr',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '激活时间',
      dataIndex: 'activatedTime',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '核销时间',
      dataIndex: 'usedTime',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '核销次数',
      dataIndex: 'activity',
      ellipsis: true,
      width: 120,
      align: 'center',
      hideInSearch: true,
      render(_, record: any) {
        return <div>{record.useStatus === 1 ? record.validStatus : '-'}</div>;
      },
    },
    {
      title: '有效开始时间',
      dataIndex: 'validStartTime',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '有效结束时间',
      dataIndex: 'validEndTime',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '餐厅号',
      dataIndex: 'storeId',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: 'POS流水号',
      dataIndex: 'merchantPosTransId',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '活动定义',
      dataIndex: 'activityId',
      ellipsis: true,
      width: 150,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '活动代码',
      dataIndex: 'activityCode',
      ellipsis: true,
      width: 180,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '订单号',
      dataIndex: 'orderId',
      ellipsis: true,
      width: 160,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '折扣类型',
      dataIndex: 'tenderType',
      ellipsis: true,
      width: 80,
      align: 'center',
      hideInSearch: true,
      render(_, record: any) {
        return <div>{record.tenderType === 2 ? '折扣' : '结算'}</div>;
      },
    },
    {
      title: '销售金额',
      dataIndex: 'couponPrice',
      ellipsis: true,
      width: 120,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '核销金额',
      dataIndex: 'financialValue',
      ellipsis: true,
      width: 120,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '预付金额',
      dataIndex: 'salePrice',
      ellipsis: true,
      width: 120,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '补贴金额',
      dataIndex: 'saleDiscount',
      ellipsis: true,
      width: 120,
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '操作',
      dataIndex: 'operation',
      width: 180,
      align: 'center',
      hideInSearch: true,
      fixed: 'right',
      render(_, record: API.CouponSearchListItem) {
        return (
          <div key={record.id}>
            <a onClick={() => handleOperate(record, '显示明显')}>显示明显</a>&nbsp;&nbsp;
            <Dropdown overlay={getItems(record)}>
              <a>
                更多 <DownOutlined />
              </a>
            </Dropdown>
          </div>
        );
      },
    },
  ];

  // 获取列表
  const getPromotionList = async (params: ParamsType) => {
    const paramsBro = filterForm.getFieldsValue();
    delete paramsBro.filterType;
    const { current, ...rest } = params;
    // filterType
    const param: any = {
      pageNo: current || 1,
      pageSize: params.pageSize || 10,
      ...rest,
      ...paramsBro,
    };

    const { code, data, msg } = await couponSearch(param);
    if (code === 200 && data) {
      const { rows, totalCount, pageSize, pageNo } = data;
      return {
        total: totalCount,
        pageSize,
        current: pageNo,
        data: rows,
      };
    } else {
      message.error(msg || '获取列表失败');
    }
    return {};
  };

  const showTotal: PaginationProps['showTotal'] = (t) => `共 ${t} 条`;

  // 表头列弹窗--删除操作
  const handleNumCancel = () => {
    modalNumForm.resetFields();
    setFileList([]);
    setFileUrlBro('');
    setModelNumVisible(false);
  };

  // 批量导出--下载文件
  const exportExcel = async () => {
    try {
      if (isEmpty(fileUrlBro)) {
        message.error('请上传文件！');
        return;
      }
      setConfirmLoad(true);
      const params = {
        fileUrl: fileUrlBro || '',
      };
      const resUpdate: any = await searchBatch(params);
      setConfirmLoad(false);

      const url = window.URL.createObjectURL(resUpdate.data);
      const link = document.createElement('a');
      link.style.display = 'none';
      const Disposition = resUpdate?.Disposition || '';
      if (!Disposition) {
        message.error('暂无数据');
        return;
      }
      link.download = decodeURIComponent(Disposition?.split(`filename=`)[1]) || '导出文件'; // 下载的文件名称
      link.href = url;
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
      message.success('批量查券成功');
      handleNumCancel();
    } catch (error) {
      message.error('批量查券失败');
    }
  };

  // 表头列弹窗--确定操作
  const handleNumOK = () => {
    modalNumForm.validateFields().then(async (values) => {
      if (modelText === '账号迁移') {
        setConfirmLoad(true);
        const params = {
          oldUserCode: values.oldUserCode,
          newUserCode: values.newUserCode,
        };
        const { code, msg } = await accountMove(params);
        setConfirmLoad(false);
        if (code === 200) {
          modalNumForm.resetFields();
          setModelNumVisible(false);
          message.success('账号迁移成功');
        } else {
          message.error(msg || '账号迁移失败');
        }
      }
      if (modelText === '批量核销券') {
        if (isEmpty(fileUrlBro)) {
          message.error('请上传文件！');
          return;
        }
        setConfirmLoad(true);
        const params = {
          activityId: values.activityId,
          fileUrl: fileUrlBro || '',
        };
        const { code, msg } = await usecouponBatch(params);
        setConfirmLoad(false);
        if (code === 200) {
          handleNumCancel();
          message.success('批量核销券成功');
        } else {
          message.error(msg || '批量核销券失败');
        }
      }
      if (modelText === '批量查券') {
        exportExcel();
      }
    });
  };

  const columnsForTable = [
    {
      title: '活动ID',
      dataIndex: 'activityid',
      width: 100,
      align: 'center',
      ellipsis: true,
      render: (text: string) => (
        <Typography.Text ellipsis={{ tooltip: text }}>{text ?? '-'}</Typography.Text>
      ),
    },
    {
      title: '数量',
      dataIndex: 'count',
      width: 80,
      align: 'center',
      render: (text: string) => (
        <Typography.Text ellipsis={{ tooltip: text }}>{text ?? '-'}</Typography.Text>
      ),
    },
    {
      title: '活动名',
      dataIndex: 'activity',
      width: 140,
      ellipsis: true,
      render: (text: string) => (
        <Typography.Text ellipsis={{ tooltip: text }}>{text ?? '-'}</Typography.Text>
      ),
      align: 'center',
    },
  ];

  const couponSumCancel = () => {
    setDataSource([]);
    setCouponSumVisible(false);
    modalNumForm.resetFields();
  };

  const handleElecOK = () => {
    // @ts-ignore
    modalElecForm.validateFields().then(async (values) => {
      setConfirmLoad(true);
      // const { code, data } = await cachetaskEdit({ ...values });
      // if (code === 200 && data) {
      //   message.success('操作成功');
      //   modalElecForm.resetFields();
      //   setModelNumVisible(false);
      //   actionRef?.current?.reloadAndRest?.();
      // }
      setConfirmLoad(false);
    });
  };

  const handleElecCancel = () => {
    setElecVisible(false);
    modalElecForm.resetFields();
  };

  const handleToolBar = (type: string) => {
    if (type === '账号迁移') {
      setModelText('账号迁移');
    }
    if (type === '批量核销') {
      setModelText('批量核销券');
    }
    if (type === '批量查询') {
      setModelText('批量查券');
    }
    setModelNumVisible(true);
  };

  const beforeUploadCrop = (file: File) => {
    console.log('文件上传之前--file', file);
    setFolder({
      ...defaultFolderValue,
      fileName: '' + uuidV4() + file.name,
    });

    const isOverSize = file.size / 1024;
    if (isOverSize > 20 * 1024) {
      message.error('文件大小必须小于20MB!');
      // message.error(`图片大小必须小于${maxSize}kb!`);
      return false;
    }
    return true;
  };

  const onFileChange: UploadProps['onChange'] = ({ file, fileList: newFileList }) => {
    console.log('UploadProps---UploadProps', file, fileList);

    if (newFileList.length === 0) {
      setFileUrlBro('');
    }

    const { status, response } = file || {};
    setFileList(newFileList);

    // 没有status，说明没有上传，是本地文件
    if (!status) {
      setFileList([...fileList]);
    }
    if (status === 'uploading') {
      setLoading(true);
    }
    if (status === 'done') {
      const { code, data } = response || {};
      if (code === '200' && data) {
        setFileUrlBro(data);
      }
      setLoading(false);
    }
    if (status === 'error') {
      setLoading(false);
      setFileList([...fileList]);
      message.error('上传失败');
    }
  };

  // 普通查询 0 归档查询 1
  const normalQuery = (type: number) => {
    filterForm.setFieldValue('queryType', type);
    const values = filterForm.getFieldsValue();
    if (isEmpty(values.mobile) && isEmpty(values.userCode) && isEmpty(values.couponCode)) {
      message.error('查询类型参数不能为空');
      return;
    }
    actionRef?.current?.reloadAndRest?.();
  };

  //  一键归档
  const keyClickQuery = async () => {
    const values = filterForm.getFieldsValue();
    if (isEmpty(values.mobile) && isEmpty(values.userCode)) {
      message.error('用户标识和手机号必须输入一个');
      return;
    }

    const { code, msg } = await couponArchive({
      userCode: values.userCode || '',
      mobile: values.mobile || '',
      brand: values.brand || '',
    });
    if (code === 200) {
      message.success('一键归档成功');
    } else {
      message.error(msg || '一键归档失败');
    }
  };

  //  券汇总
  const summarizeQuery = async () => {
    const values = filterForm.getFieldsValue();
    if (isEmpty(values.mobile) && isEmpty(values.userCode)) {
      message.error('用户标识和手机号必须输入一个');
      return;
    }

    setCouponSumVisible(true);
    setSumText('券汇总详情');
    const { code, msg, data } = await couponSummarize({
      userCode: values.userCode || '',
      mobile: values.mobile || '',
      brand: values.brand || '',
    });
    if (code === 200 && data) {
      setDataSource(data);
    } else {
      message.error(msg || '券汇总操作失败');
    }
  };

  // 归档操作汇总
  const queryBro = (type: string) => {
    setQueryText(type);
    if (type === '一键归档') {
      keyClickQuery();
      return;
    }
    if (type === '券汇总') {
      summarizeQuery();
      return;
    }
    if (type === '归档查询') {
      setQueryText('归档查询');
      normalQuery(1);
      return;
    }
  };

  return (
    <PageContainer>
      <div className={styles['form-body']}>
        <div className={styles['filter-body']}>
          <Form
            labelCol={{ span: 6 }}
            form={filterForm}
            initialValues={{
              queryType: 0,
              filterType: 1,
              couponCode: '',
              userCode: '',
              mobile: '',
              brand: OptionsBrandList ? OptionsBrandList[0].value : '',
              orderId: '',
              status: '全部',
            }}
          >
            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
              <div style={{ display: 'flex' }}>
                <Form.Item label="queryType" name="queryType" hidden>
                  <Input autoComplete="off" />
                </Form.Item>

                <Form.Item label={null} name="filterType" style={{ width: 105, marginRight: 5 }}>
                  <Select
                    options={[
                      { label: '券号', value: 1 },
                      { label: '用户标识', value: 2 },
                      { label: '手机号', value: 3 },
                    ]}
                  />
                </Form.Item>
                <Form.Item
                  label={null}
                  name={filterNameEnum[filterTypeWatch]}
                  style={{ width: 200, marginRight: 30 }}
                >
                  <Input placeholder={filterPlaEnum[filterTypeWatch]} autoComplete="off" />
                </Form.Item>
                <Form.Item label="订单号" name="orderId" style={{ width: 300, marginRight: 30 }}>
                  <Input placeholder="请输入" autoComplete="off" />
                </Form.Item>
                <Form.Item label="状态" name="status" style={{ width: 300, marginRight: 30 }}>
                  <Select
                    options={[
                      { label: '全部', value: '全部' },
                      { label: '可用', value: '可用' },
                    ]}
                  />
                </Form.Item>
              </div>
              <div style={{ display: 'flex' }}>
                <Button
                  style={{ marginRight: 10 }}
                  key="reset"
                  onClick={() => {
                    filterForm.resetFields();
                    // 重置完 条件为空，无法查询所以注释
                    // setQueryText('普通查询');
                    // normalQuery(0);
                    // actionRef?.current?.reloadAndRest?.();
                  }}
                >
                  重置
                </Button>
                <Button
                  style={{ marginRight: 10 }}
                  type="primary"
                  key="query"
                  onClick={() => {
                    setQueryText('普通查询');
                    normalQuery(0);
                  }}
                >
                  查询
                </Button>
              </div>
            </div>
            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
              <div>
                {filterTypeWatch === 3 && (
                  <Form.Item label="用户品牌" name="brand" style={{ width: 310, marginRight: 30 }}>
                    <Select options={OptionsBrandList} />
                  </Form.Item>
                )}
              </div>
              <div style={{ display: 'flex', paddingBottom: 24 }}>
                <Button
                  style={{ marginRight: 10 }}
                  type="primary"
                  key="back"
                  onClick={() => {
                    queryBro('一键归档');
                  }}
                >
                  一键归档
                </Button>
                <Button
                  style={{ marginRight: 10 }}
                  type="primary"
                  key="sum"
                  onClick={() => {
                    queryBro('券汇总');
                  }}
                >
                  券汇总
                </Button>
                <Button
                  style={{ marginRight: 10 }}
                  type="primary"
                  key="query"
                  onClick={() => {
                    queryBro('归档查询');
                  }}
                >
                  归档查询
                </Button>
              </div>
            </div>
          </Form>
        </div>
        <ProTable<API.CouponSearchListItem>
          manualRequest={true}
          rowKey="id"
          columns={columns}
          actionRef={actionRef}
          formRef={formRef}
          request={getPromotionList}
          options={false}
          search={false}
          toolBarRender={() => [
            <Button
              type="primary"
              key="move"
              onClick={() => {
                handleToolBar('账号迁移');
              }}
            >
              账号迁移
            </Button>,
            <Button
              type="primary"
              key="check"
              onClick={() => {
                handleToolBar('批量核销');
              }}
            >
              批量核销
            </Button>,
            <Button
              type="primary"
              key="query"
              onClick={() => {
                handleToolBar('批量查询');
              }}
            >
              批量查询
            </Button>,
          ]}
          headerTitle="手机号："
          scroll={{ x: 800 }}
          pagination={{
            showSizeChanger: true,
            size: 'small',
            showTotal,
            showQuickJumper: true,
            defaultPageSize: 10,
          }}
        />
        {/* 券汇总详情 */}
        <Modal
          title={sumText}
          width={620}
          open={couponSumVisible}
          onCancel={couponSumCancel}
          footer={null}
        >
          {sumText === '券汇总详情' && (
            <Table
              // @ts-ignore
              columns={columnsForTable}
              dataSource={dataSource}
              // scroll={{ y: 1500 }}
              pagination={false}
            />
          )}

          {sumText === '券明细信息' && (
            <Form.Item label="券明细" name="cacheValue">
              <Input.TextArea rows={6} disabled value={'123'} />
            </Form.Item>
          )}
        </Modal>

        <Modal
          title={modelText}
          width={520}
          open={modelNumVisible}
          onOk={handleNumOK}
          onCancel={handleNumCancel}
          confirmLoading={confirmLoad}
        >
          <Form
            labelCol={{ span: 6 }}
            form={modalNumForm}
            initialValues={{
              oldUserCode: '',
              newUserCode: '',
              activityId: '',
            }}
          >
            {modelText === '账号迁移' && (
              <>
                <Form.Item
                  label="原用户标识"
                  name="oldUserCode"
                  rules={[
                    {
                      required: true,
                      message: '不得为空',
                    },
                  ]}
                >
                  <Input autoComplete="off" placeholder="OldUserCode" />
                </Form.Item>

                <Form.Item
                  label="新用户标识"
                  name="newUserCode"
                  rules={[
                    {
                      required: true,
                      message: '不得为空',
                    },
                  ]}
                >
                  <Input autoComplete="off" placeholder="NewUserCode" />
                </Form.Item>
              </>
            )}
            {modelText === '批量核销券' && (
              <Form.Item
                label="活动定义"
                name="activityId"
                rules={[
                  {
                    required: true,
                    message: '不得为空',
                  },
                ]}
              >
                <Input autoComplete="off" placeholder="ActivityId" />
              </Form.Item>
            )}
            {['批量核销券', '批量查券'].includes(modelText) && (
              <Form.Item label="券码" name="fileUrl">
                <Upload
                  name="file"
                  accept=".txt"
                  listType={'text'}
                  headers={{
                    ticket: `${StorageManager.getLocalStorageSync('token')}`,
                    contentType: 'multipart/form-data',
                  }}
                  fileList={fileList}
                  action={`${API_CONFIGS.server}${API_CONFIGS.prefix}/common/upload`}
                  beforeUpload={beforeUploadCrop}
                  onChange={onFileChange}
                  data={folder}
                >
                  {fileList.length === 0 && (
                    <Button type="primary" loading={loading}>
                      文件上传
                    </Button>
                  )}
                </Upload>
              </Form.Item>
            )}
          </Form>
        </Modal>

        <Modal
          title="操作电子券"
          width={520}
          open={elecVisible}
          onOk={handleElecOK}
          onCancel={handleElecCancel}
          confirmLoading={confirmLoad}
        >
          <Form
            labelCol={{ span: 6 }}
            form={modalElecForm}
            initialValues={{
              id: '',
            }}
          >
            <Form.Item label="券码" name="cacheValue">
              <Input autoComplete="off" />
            </Form.Item>
            <Form.Item label="操作类型" name="cacheValue">
              <Select options={EnumElecStatusOption} />
            </Form.Item>
          </Form>
        </Modal>
      </div>
    </PageContainer>
  );
};

export default SensitizeManageList;
